using System.Configuration;
using System.Data;
using MySql.Data.MySqlClient;

namespace TimeSheetDAL
{
    /// <summary>
    /// Summary description for DBConnect.
    /// </summary>
    public class DBConnect
    {
        public static readonly DBConnect Instance = new DBConnect();
        private static string DATA_SOURCE;
        //private IDbConnection conn;

        private DBConnect()
        {
            DATA_SOURCE =
                ConfigurationSettings.AppSettings[
                    "Main.ConnectionString"];
        }

        public IDbCommand GetCommand(string statement, IDbConnection conn)
        {
            return new MySqlCommand(statement, (MySqlConnection) conn);
        }

        public IDbDataAdapter GetDataAdapter(string statement, IDbConnection conn)
        {
            return new MySqlDataAdapter(statement, (MySqlConnection) conn);
        }

        /// <summary>
        /// Returns a new MySQLConnection
        /// </summary>
        /// <returns></returns>
        public IDbConnection GetConnection()
        {
            return new MySqlConnection(DATA_SOURCE);
        }
    } //class
} //namespace